const express = require("express");
// const logger = require('morgan');
const Routes = require("./route/index");
const Bus = require("./event/message-center");
const {
  setCors,
  setReqTimeout,
  useCookieParser,
  setPostConfig,
  setStaticPath,
} = require("./utils").middleware;
const { RequestTimeOut } = require("./config/apiConfig").serverConfig;
const { useLogger } = require("./utils/log");
const app = express();
useLogger(app); //日志
setCors(app); //跨域
useCookieParser(app); //cookie
setReqTimeout(app, RequestTimeOut); //请求超时
setPostConfig(app, express); //post请求处理
setStaticPath(app, express, "/publie", "./public"); //静态目录
// app.use(logger('dev'));
new Routes(app); //初始化路由
new Bus(app); //事件总线
module.exports = app;
